package com.code.controller;

import com.code.entity.Result;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("login")
public class LoginController {
//    @RequestMapping("name")
//    public Object name(){
//       String name= SecurityContextHolder.getContext().getAuthentication().getName();
//        return name;
//    }

    @RequestMapping("username")
    public Map findUserName(){
        String name = SecurityContextHolder.getContext().getAuthentication().getName();
        HashMap hashMap = new HashMap();
        hashMap.put("username",name);
        return hashMap;
    }
}
